package by.dezhits.liltweets.bo;

import org.json.JSONException;
import org.json.JSONObject;

public class User {
	private String name;
	private String screenName;
	private String profileImageUrl;
	private String followersCount;
	private String statusesCount;
	private String friendsCount;
	
	private String id;
	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getScreenName() {
		return screenName;
	}

	public String getProfileImageUrl() {
		return profileImageUrl;
	}

	public String getFollowersCount() {
		return followersCount;
	}

	public String getStatusesCount() {
		return statusesCount;
	}

	public String getFriendsCount() {
		return friendsCount;
	}

	
	
	public User(String s) throws JSONException {
		JSONObject user = new JSONObject(s);
		id = user.getString("id");
		name = user.getString("name");
		screenName = user.getString("screen_name");
		followersCount = user.getString("followers_count");
		statusesCount = user.getString("statuses_count");
		friendsCount = user.getString("friends_count");
		String imageSmallUrl = user.getString("profile_image_url");
		profileImageUrl = getNormalSizePictureUrl(imageSmallUrl);
	}
	
	public String getNormalSizePictureUrl(String profileImageURL) {
		String normalSuffix = "_normal";
		int b = profileImageURL.indexOf(normalSuffix, 0);
		int e = b + normalSuffix.length();
		StringBuilder s = new StringBuilder();
		s.append(profileImageURL.substring(0, b)).append(
				profileImageURL.substring(e, profileImageURL.length()));
		return s.toString();
	}
}
